package com.cgc.dao.impl;

import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.MatchMode;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Component;

import com.cgc.dao.IDeptDao;
import com.cgc.entity.Dept;

@Component
public class DeptDaoImpl extends BaseDaoImpl<Dept> implements IDeptDao<Dept>  {

	@Override
	public DetachedCriteria getDetachedCriteria(Dept dept){
		DetachedCriteria dc = DetachedCriteria.forClass(Dept.class);
		if(dept!=null){
			if(null!=dept.getName() && dept.getName().trim().length()>0){
				dc.add(Restrictions.like("d_name", dept.getName(),MatchMode.ANYWHERE));
			}
			if(null!=dept.getTele() && dept.getTele().trim().length()>0){
				dc.add(Restrictions.like("d_address", dept.getTele(),MatchMode.ANYWHERE));
			}
		}
	
		return dc;
		
	}
}
